home *** CD-ROM | disk | FTP | other *** search
Java Source | 1996-09-25 | 1.1 KB | 54 lines |
- //
- // chgclr.java
- // change current color of color panel
- //
- // (c) Copyright 1996 Sony Corporation. All rights reserved.
-
- import vrml.*;
- import vrml.field.*;
- import vrml.node.*;
- import java.util.*;
-
- public class chgclr extends Script {
- SFColor diffuse;
- SFInt32 no;
- float f[] = new float[3];
- final int COLOR_MAX = 18;
-
- public void processEvent(Event e){
- if( ((ConstSFBool)e.getValue()).getValue() == true ){
- String str = e.getName();
-
- // System.out.println( "chgclr: " + str );
-
- try{
- if( str.startsWith( "clicked" )){
- Integer ii = new Integer (str.substring( 7 ));
- int i = ii.intValue();
- if ( i >= 0 && i < COLOR_MAX ){
- diffuse.setValue( GenerateColor.getSFColor( i ));
- no.setValue( i );
- }
- }
- else{
- getBrowser().setDescription ( "invalid header:" + str );
- }
- } catch ( Exception ex ){
- getBrowser().setDescription ( "error: wrl file is not correct." );
- }
-
- }
- }
- public void initialize (){
- diffuse = ( SFColor ) getEventOut("diffuse") ;
- no = ( SFInt32 ) getEventOut("no") ;
- }
- }
-
-
-
-
-
-
-
-